package ext.tianma.bom.service.rfq;

import java.io.PrintWriter;
import java.util.Hashtable;
import java.util.Iterator;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.json.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.alibaba.fastjson.JSON;

@Controller
@RequestMapping({ "/rfq"})
public class RFQController {
	
	@RequestMapping(value = "/rfqPart",  method = {
			RequestMethod.POST, RequestMethod.GET
	})
	public void getRFQPart(
			@RequestBody String data,
			HttpServletResponse response) throws Exception {
		boolean enforced = wt.session.SessionServerHelper.manager.setAccessEnforced(false);
		PrintWriter out = response.getWriter();
		response.setContentType("text/html;charset=UTF-8");
		
		JSONObject obj = new JSONObject(data);
		//String number = obj.getString("number").trim();
		//String name = obj.getString("name").trim();
		
		String parts = obj.getString("parts").trim();
		String ibaValues = obj.getString("ibaValues").trim();
		String userCode = obj.getString("userCode").trim();
		String rfqNum = obj.getString("rfqNum").trim();
	
		/*String number = request.getParameter("number");
		String name = request.getParameter("name");
		String docNum = request.getParameter("docNum");
		String ibaValues = request.getParameter("ibaValues");*/
		String partName = RFQService.createFinishedPart(parts, ibaValues, rfqNum, userCode);
		out.println(partName);
		
		wt.session.SessionServerHelper.manager.setAccessEnforced(enforced);
		
	}
}
